import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { OrderListComponent } from './order-list/order-list.component';

@Component({
  selector: 'app-order-manage',
  templateUrl: './order-manage.component.html',
  styleUrls: ['./order-manage.component.scss']
})
export class OrderManageComponent implements AfterViewInit {
  @ViewChild(OrderListComponent)
  public getOrderList!: OrderListComponent

  selectedItem = "orders";
  tabActiveId: string | number = "orders"
  orderName: string
  menuArray = [
    {
      title: "全部订单",
      id: "orders",
    },
    {
      title: "待付款",
      id: "unfinished",
    },
    {
      title: "已完成",
      id: "finished",
    },
    {
      title: "已取消",
      id: "canceled",
    },
  ];

  activeTabChange(tab) {
    this.selectedItem = tab
    this.getOrderList.getList(tab, this.orderName)
  }

  submitForm($event) {
    this.getOrderList.getList(this.selectedItem, this.orderName)
  }

  constructor() { }

  ngAfterViewInit(): void {
    this.getOrderList.getList(this.selectedItem, this.orderName)
  }
}
